﻿using UnityEngine;

public class JumpController : ActionController
{
    public float JumpHeight
    {
        set => jumpSpeed = Mathf.Sqrt(value * -Physics2D.gravity.y * 2);
    }
    private float jumpSpeed;

    protected override void OnStart()
    {
        JumpHeight = 3.2f;
    }

    private void FixedUpdate()
    {
        if (player.b_wantJump)
        {
            Jump();
            player.b_wantJump = false;
        }
    }
    private void Jump()
    {
        if (!player.Grounded)
            return;

        m_rigidbody.velocity = new Vector2(m_rigidbody.velocity.x, jumpSpeed);
    }
}
